package ncorps.output;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import ncorps.commun.StatNewtonFourier;

public class FileOut {

    public static void printf(String filename, StatNewtonFourier stat) throws FileNotFoundException, IOException {
        FileOutputStream stream = new FileOutputStream(new File(".").getCanonicalPath() + "/STAT/" + filename);
        PrintStream printStream = new PrintStream(stream);
        printStream.print("Difference moyenne X :  ");
        printStream.println(stat.getDifferenceMoyenne_X());
        printStream.print("Difference moyenne Y :  ");
        printStream.println(stat.getDifferenceMoyenne_Y());
        printStream.print("Variance X :  ");
        printStream.println(stat.getVariance_X());
        System.out.println(stat.getVariance_X());
        printStream.print("Variance Y :  ");
        printStream.println(stat.getVariance_Y());
        System.out.println(stat.getVariance_Y());
        printStream.println();
        stream.close();
    }

    public static void printf(String filename, double[] tab, int NbCorps) throws FileNotFoundException, IOException {
        FileOutputStream stream = new FileOutputStream(new File(".").getCanonicalPath() + "/FILE/" + filename);
        PrintStream printStream = new PrintStream(stream);
        for (int n = 0; n < NbCorps; n++) {
            printStream.println(tab[n]);
        }
        printStream.println();
        stream.close();
    }

    public static void printf(String repfiles, String filename, double[][] tab, int NbCorps, boolean force) throws FileNotFoundException, IOException {
//        FileOutputStream stream = new FileOutputStream(new File(".").getCanonicalPath() + "/FILE/" + filename);
        FileOutputStream stream = new FileOutputStream(repfiles + filename);
        PrintStream printStream = new PrintStream(stream);
        if (!force) {
            for (int n = 0; n < NbCorps; n++) {
                printStream.print(tab[n][1] + " " + tab[n][2] + " " + tab[n][3] + " " + tab[n][4]);
                printStream.println();
            }
        } else {
            for (int n = 0; n < NbCorps; n++) {
                printStream.print(tab[n][0] + " " + tab[n][1]);
                printStream.println();
            }
        }
        printStream.println();
        stream.close();
    }
}







